// 定义user下的请求
import type { CodeType, Patient, User, UserInfo } from '@/types/user'
import { request } from '@/utils/request'

// 密码登录
export const loginByPassword = (mobile: string, password: string) =>
  request<User>('/login/password', 'POST', { mobile, password })

//获取验证码(此处后台不会返回数据,所以不用泛型)
export const sendMobileCode = (mobile: string, type: CodeType) =>
  request('code', 'GET', { mobile, type })

//验证码登录
export const loginByCode = (mobile: string, code: string) =>
  request<User>('login', 'POST', { mobile, code })

// 获取个人信息
export const getUserInfo = () => request<UserInfo>('/patient/myUser')

// 获取患者信息列表
export const getPatientList = () => request<Patient[]>('/patient/mylist')

// 添加患者
export const addPatient = (patient: Patient) =>
  request('/patient/add', 'POST', patient)

// 编辑患者
export const editPatient = (patient: Patient) =>
  request('/patient/update', 'PUT', patient)

// 删除患者信息
export const delPatient = (id: string) =>
  request(`/patient/del/${id}`, 'DELETE')
